package com.idrem.views.home;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.idrem.R;
import com.idrem.views.location.LocationAct;
import com.idrem.views.login.LoginActivity;
import com.idrem.views.report.ReportAct;
import com.idrem.views.sync.SyncMainAct;
import com.idrem.views.visit.VisitMainAct;

public class HomeAct extends Activity {
	private static String TAG = "HomeAct";
	private ImageView mainCustomer;
	private ImageView mainGoods;
	private ImageView mainInformation;
	private ImageView mainInventory;
	private ImageView mainMore;
	private ImageView mainOrder;
	private ImageView mainReporting;
	private ImageView mainSync;
	private ImageView mainVisit;

	public class MyListener implements View.OnClickListener {

		public void onClick(View v) {
			Intent intent = null;
			switch (v.getId()) {
			case R.id.main_iv_visit:
				intent = new Intent(HomeAct.this, VisitMainAct.class);
				startActivity(intent);
				break;
			case R.id.main_iv_order:
				Toast.makeText(HomeAct.this, "orderActivty", Toast.LENGTH_SHORT).show();
				break;
			case R.id.main_iv_inventory:
				Toast.makeText(HomeAct.this, "inventoryActivty", Toast.LENGTH_SHORT).show();
				break;
			case R.id.main_iv_customer:
				Toast.makeText(HomeAct.this, "customerActivty", Toast.LENGTH_SHORT).show();
				break;
			case R.id.main_iv_goods:
				Toast.makeText(HomeAct.this, "goodsActivty", Toast.LENGTH_SHORT).show();
				break;
			case R.id.main_iv_reporting:
				intent = new Intent(HomeAct.this, ReportAct.class);
				startActivity(intent);				
				break;
			case R.id.main_iv_information:
				intent = new Intent(HomeAct.this, LocationAct.class);
				startActivity(intent);			
				break;
			case R.id.main_iv_sync:
				intent = new Intent(HomeAct.this, SyncMainAct.class);
				startActivity(intent);
				break;
			case R.id.main_iv_more:
				Toast.makeText(HomeAct.this, "moreActivty", Toast.LENGTH_SHORT).show();
				break;
			default:
				break;
			}
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);	
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);		
		setContentView(R.layout.homemain);
		
        Intent intent=getIntent();
        String usrNm=intent.getStringExtra("user");
		TextView txt = (TextView)findViewById(R.id.tv_information);		 
		txt.setText("您好："+usrNm);
		
		this.mainVisit = ((ImageView) findViewById(R.id.main_iv_visit));
		this.mainOrder = ((ImageView) findViewById(R.id.main_iv_order));
		this.mainInventory = ((ImageView) findViewById(R.id.main_iv_inventory));
		this.mainCustomer = ((ImageView) findViewById(R.id.main_iv_customer));
		this.mainGoods = ((ImageView) findViewById(R.id.main_iv_goods));
		this.mainReporting = ((ImageView) findViewById(R.id.main_iv_reporting));
		this.mainInformation = ((ImageView) findViewById(R.id.main_iv_information));
		this.mainSync = ((ImageView) findViewById(R.id.main_iv_sync));
		this.mainMore = ((ImageView) findViewById(R.id.main_iv_more));

		MyListener listener = new MyListener();

		this.mainVisit.setOnClickListener(listener);
		this.mainOrder.setOnClickListener(listener);
		this.mainInventory.setOnClickListener(listener);
		this.mainCustomer.setOnClickListener(listener);
		this.mainGoods.setOnClickListener(listener);
		this.mainReporting.setOnClickListener(listener);
		this.mainInformation.setOnClickListener(listener);
		this.mainSync.setOnClickListener(listener);
		this.mainMore.setOnClickListener(listener);
	}

}
